<%@ page contentType="text/html;charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div class="page clearfloat">
	<div class="mess">共有${page.maxPage}页</div>
	<ul>
		<c:choose>
			<c:when test="${page.pageNum > 1}">
				<li class="first "><a href="javascript:void(0)" onclick="submitPaging(1)"><i>&#xe626;</i></a></li>
				<li class="prev "><a href="javascript:void(0)" onclick="submitPaging(${page.pageNum-1})"><i>&#xe624;</i></a></li>
			</c:when>
			<c:otherwise>
				<li class="first disable"><a><i>&#xe626;</i></a></li>
				<li class="prev disable"><a><i>&#xe624;</i></a></li>
				<c:if test="${page.maxRow==0}">
					<li class="curr"><a>0</a></li>
				</c:if>
			</c:otherwise>
		</c:choose>

		<c:choose>
			<c:when test="${page.maxPage <= 5}">
				<c:forEach var="index" begin="1" end="${page.maxPage}" step="1">
					<c:choose>
						<c:when test="${page.pageNum == index}">
							<li class="curr">${index}</li>
						</c:when>
						<c:otherwise>
							<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
						</c:otherwise>
					</c:choose>
				</c:forEach>
			</c:when>

			<c:otherwise>
				<c:choose>
					<c:when test="${page.pageNum-1 <= 2}">
						<c:forEach var="index" begin="1" end="${page.maxPage}" step="1">
							<c:choose>
								<c:when test="${page.pageNum == index}">
									<li class="curr">${index}</li>
								</c:when>
								<c:otherwise>
									<c:choose>
										<c:when test="${page.maxPage < 5}">
											<c:if test="${index == 1}">
												<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
											</c:if>
											<c:if test="${index == 2}">
												<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
											</c:if>
											<c:if test="${index == 3}">
												<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
											</c:if>
											<c:if test="${index == 4}">
												<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
											</c:if>
										</c:when>
										<c:otherwise>
											<c:if test="${index == 1}">
												<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
											</c:if>
											<c:if test="${index == 2}">
												<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
											</c:if>
											<c:if test="${index == 3}">
												<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
											</c:if>
											<c:if test="${index == 4}">
												<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
											</c:if>
											<c:if test="${index == 5}">
												<li>...
												<li>
											</c:if>
											<c:if test="${index == page.maxPage && index != 1 && index != 2 && index != 3 && index != 4}">
												<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
											</c:if>
										</c:otherwise>
									</c:choose>
								</c:otherwise>
							</c:choose>
						</c:forEach>
					</c:when>
					<c:otherwise>
						<c:choose>
							<c:when test="${(page.maxPage - page.pageNum) < 2}">
								<c:forEach var="index" begin="1" end="${page.maxPage}" step="1">
									<c:if test="${index == 1}">
										<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a>
										<li>
									</c:if>
									<c:if test="${index == page.pageNum}">
										<li class="curr">${index}</li>
									</c:if>
									<c:if test="${index == 2}">
										<li>...</li>
									</c:if>
									<c:if test="${page.pageNum != index}">
										<c:if test="${index == (page.maxPage - 3)}">
											<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a>
											<li>
										</c:if>
										<c:if test="${index == (page.maxPage - 2)}">
											<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
										</c:if>
										<c:if test="${index == (page.maxPage - 1)}">
											<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
										</c:if>
										<c:if test="${index == page.maxPage}">
											<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
										</c:if>
									</c:if>
								</c:forEach>
							</c:when>
							<c:otherwise>
								<c:forEach var="index" begin="1" end="${page.maxPage}" step="1">
									<c:if test="${index == 1}">
										<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
									</c:if>
									<c:if test="${index == 2}">
										<li>...</li>
									</c:if>
									<c:if test="${index == (page.pageNum - 1)}">
										<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
									</c:if>
									<c:if test="${index == page.pageNum}">
										<li class="curr">${index}</li>
									</c:if>
									<c:if test="${index == (page.pageNum + 1)}">
										<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
									</c:if>
									<c:if test="${index == (page.pageNum + 2) && page.maxPage == (page.pageNum + 2)}">
										<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
									</c:if>
									<c:if test="${index == (page.pageNum + 2) && page.maxPage != (page.pageNum + 2)}">
										<li>...</li>
									</c:if>
									<c:if test="${index == page.maxPage && index != (page.pageNum + 2)}">
										<li><a href="javascript:void(0)" onclick="submitPaging(${index})">${index}</a></li>
									</c:if>
								</c:forEach>
							</c:otherwise>
						</c:choose>
					</c:otherwise>
				</c:choose>
			</c:otherwise>
		</c:choose>

		<c:choose>
			<c:when test="${page.pageNum < page.maxPage}">
				<li class="next "><a href="javascript:void(0)" onclick="submitPaging(${page.pageNum+1})"><i>&#xe627;</i></a></li>
				<li class="last "><a href="javascript:void(0)" onclick="submitPaging(${page.maxPage})"><i>&#xe625;</i></a></li>
			</c:when>
			<c:otherwise>
				<li class="next disable"><a><i>&#xe627;</i></a></li>
				<li class="last disable"><a><i>&#xe625;</i></a></li>
			</c:otherwise>
		</c:choose>
	</ul>
	<form action="javascript:void(0);">
		<div class="input">
			<input type="text" name="index" id="index" value="${page.pageNum}">
			<input type="hidden" name="maxNum" id="maxNum" value="${page.maxPage}">
		</div>
		<div class="btn">
			<input type="button" value="GO" onclick="GO()">
		</div>
	</form>
</div>

<script type="text/javascript">
	function GO() {
		var index=parseInt(document.getElementById("index").value);
		var maxNum=parseInt(document.getElementById("maxNum").value);
		 var re =  /^[1-9]+[0-9]*]*$/ ;   //判断字符串是否为数字     //判断正整数
		 if (!re.test(index))
		    {
			 document.getElementById("index").value = "";
		        return false;
		    }
		 //超过最大页取最大页数
		 if(index>maxNum){
			 index=maxNum;
		 }
		submitPaging(index);
	}

</script>
<!-- <span class="jicolor">共${page.maxPage}页</span> -->